package com.lzcu.maoyan.mapreduce.mapreduce.mapper;

import com.lzcu.maoyan.mapreduce.mapreduce.unit.MovieTypeWritable;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author WangLiang
 * @date `2024/4/24`
 */
public class MovieTypeMapper extends Mapper<NullWritable, MovieTypeWritable, Text, Text> {
    @Override
    protected void map(NullWritable key, MovieTypeWritable value, Context context)
            throws IOException, InterruptedException {
        String movieType = value.getSourceMovieType();
        if (movieType != null) {
            String[] movieTypeList = movieType.split("／");
            for (String type : movieTypeList) {
                context.write(new Text(type), new Text(value.getSourceMovieName()));
            }
        }
    }
}
